Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@commitlint/lint
Advanced tools
The @commitlint/lint package is a part of the commitlint toolset that is used to lint commit messages according to a specified set of rules. It helps maintain a consistent commit history and enforces a commit message convention, which is beneficial for automated processing of commit logs, generating changelogs, and aiding in code reviews.
Linting Commit Messages
This feature allows you to lint commit messages using a set of predefined rules. The code sample demonstrates how to use the lint function to check if a commit message follows the specified rules for the commit type and subject case.
const { lint } = require('@commitlint/lint');
const message = 'feat: add new feature';
const rules = {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']]
};
lint(message, rules).then(report => {
console.log(report);
});
commitlint is the core package that includes @commitlint/lint as part of its toolset. It provides a CLI and can be extended with plugins and shareable configurations. It is essentially the same tool but with a broader scope.
conventional-changelog-lint is a predecessor to commitlint and offers similar functionality for linting commit messages based on the conventional changelog standard. It has been deprecated in favor of commitlint.
validate-commit-msg is another deprecated package that was used to validate commit messages. It has been replaced by commitlint, which offers a more modern and flexible approach to commit message validation.
Lint a string against commitlint rules
npm install --save @commitlint/lint
const lint = require('@commitlint/lint').default;
lint('foo: bar', {'type-enum': [1, 'always', ['foo']]}).then((report) =>
console.log(report)
);
// => { valid: true, errors: [], warnings: [] }
lint('foo: bar', {'type-enum': [1, 'always', ['bar']]}).then((report) =>
console.log(report)
);
/* =>
{ valid: true,
errors: [],
warnings:
[ { level: 1,
valid: false,
name: 'type-enum',
message: 'type must be one of [bar]' } ] }
*/
Consult docs/api for comprehensive documentation.
FAQs
Lint a string against commitlint rules
We found that @commitlint/lint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.